using UnityEngine;
using System.Collections;
using System.Collections.Generic;

using MiniJSONx;

public class NAID_JSONParser {
	
	public static List<NAID_Data.DialogueSpeaker> ParseSpeakers()
	{
		List<NAID_Data.DialogueSpeaker> ret = new List<NAID_Data.DialogueSpeaker>();
		
		
		TextAsset jsonText = Resources.Load("NAID Resources/VNSpeakers", typeof(TextAsset)) as TextAsset;
		
		Hashtable h = MiniJSONx.Json.Deserialize(jsonText.text) as Hashtable;
		ArrayList contents = h["Speakers"] as ArrayList;
		
		foreach(Hashtable speaker in contents)
		{
			NAID_Data.DialogueSpeaker spk = new NAID_Data.DialogueSpeaker();
			
			spk.DisplayName = speaker["DisplayName"] as string;
			spk.FullName = speaker["FullName"] as string;
			
			ArrayList color = speaker["TextColor"] as ArrayList;
			
			float r = float.Parse(color[0].ToString());
			float g = float.Parse(color[1].ToString());
			float b = float.Parse(color[2].ToString());
			float a =float.Parse(color[3].ToString()); 
			
			spk.TextColor = new Color(r,g,b,a);
			
			ret.Add(spk);
			
		}
		
		return ret;
	}
	
}
